﻿using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAO;

namespace BUS
{
    public class BC_LP_BUS
    {
        public static void LapBC(long mBC, long tBC)
        {
            BC_LP_DAO.LapBC(mBC, tBC);

            List<LoaiPhongDTO> LP = LoaiPhongBUS.LayDSLP();

            for (int i = 0; i < LP.Count; i++)
            {
                BC_LP_ChiTietBUS.LapBC(mBC, LP[i].MaLoaiPhong);
            }
        }

        public static bool UpdateTDT(long mBC, double tDT)
        {
            return BC_LP_DAO.UpdateTDT(mBC, tDT);
        }

        public static bool KtMaBC(long mBC)
        {
            return BC_LP_DAO.KtMaBC(mBC);
        }

        public static double TinhTDT(long mBC, long tBC)
        {
            BC_LP_ChiTietBUS.TinhDT(mBC, tBC);

            List<BC_LP_ChiTietDTO> L = BC_LP_ChiTietBUS.LayDSTheoMBC(mBC);
            double tDT = 0;

            for (int i = 0; i < L.Count; i++)
            {
                tDT = tDT + L[i].DoanhThu;
            }

            BC_LP_DAO.UpdateTDT(mBC, tDT);

            return tDT;
        }
    }
}
